﻿ 
function SaveReply()
{ 
    $.ajax({
        async: true,
        type: "POST",
        url:  "topic_replies.aspx",
        data: {
            otype:                  "savereply",
            comments:               $("#txtComments").val(), 
            author:                 $("#txtAuthor").val(),
            email:                 $("#txtEmail").val(),
            title:                 $("#txtTitle").val(),
            tid:                   getUrlParam("tid")
        },
        beforeSend: function() { 
            $("#loading1").css("display", "");
        },
        success: function(data, textStatus) {
            $("#loading1").css("display", "none");
            if(data == "succeeded")
            {
                alert("回复成功！");
                LoadingRepliesList("divcommentslist"); 
                $("#txtComments").val("");
                $("#txtAuthor").val("");
                $("#txtEmail").val("");
                $("#txtTitle").val("");
            }
            else
            {
                alert(data);
            }
        }
    });
}
function LoadingRepliesList(tagObjectId)
{   
    $.ajax({
        async: true,
        type: "POST",
        url:  "topic_replies.aspx",
        data: {
            otype:          "loadingrepliesitems", 
			tid:   getUrlParam("tid") 
        },
        beforeSend: function() {
            $("#"+tagObjectId).html("");
            $("#"+tagObjectId).html($("#loading1").html());
        },
        success: function(data, textStatus) {  
            $("#"+tagObjectId).html("");
            $("#"+tagObjectId).html(data);
        }
    });
} 
function GetRepliesCount()
{
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/topiclist_replies.aspx"),
        data: {
            otype:          "getrepliescount",
            b_id:          getUrlParam("b_id")
        }, 
        success: function(data, textStatus) {   
            $("#repliescount").html(data);
        }
    });
}
var _PageIndex; 
function LoadingBBSList(tagObjectId)
{ 
    var _querytext = $("#searchReviewKeyWord").val();
    if(_querytext == $("#searchReviewKeyWord").attr("init_value"))
        _querytext = "";
    
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/bbs.aspx"),
        data: {
            otype:          "loadingbbsitems", 
			columnid:   getUrlParam("columnid"),
            page:           _PageIndex, 
            querytext:      _querytext
        },
        beforeSend: function() {
            $("#"+tagObjectId).html("");
            $("#"+tagObjectId).html($("#loading1").html());
        },
        success: function(data, textStatus) {  
            $("#"+tagObjectId).html("");
            $("#"+tagObjectId).html(data);
        }
    });
}
var TagObjectId = "";
function pagination(page)
{
    _PageIndex=page;  
    LoadingBBSList(TagObjectId);
}
function QueryTopics()
{
    _PageIndex=1; 
    LoadingBBSList("divtopicslist");
}  

function LoadColumnsList()
{ 
	$.ajax({
			async   :   false,
			type    :   "POST",
			url:  "bbs.aspx", 
			data    :   { otype : "getcolumns" },
			success :   function(data, textStatus) {  
				$("#selColumns").append(data);  
			}
		});
} 

function DeleteReplies(objectid)
{
    $.ajax({
        async: true,
        type: "POST",
        url:  prependOrgName("/website_admin/bbs/topic_replies.aspx"),
        data: {
            otype:          "delete",
            tid:          getUrlParam("tid"),
            r_id:          objectid
        }, 
        success: function(data, textStatus) { 
            if(data == "succeeded")
            {
                alert("删除成功！");
                LoadingRepliesList("divcommentslist");
            }
            else
            { 
                alert("操作失败！");
            }
        }
    });
}